Metaprogramming Ruby 2
Author: Paolo Perrotta , Date: July 18, 2015
, Views: 524
def self.now; 'Mon Apr 06 12:15:50'; end
end
require 'test/unit'
class TestLoan < Test::Unit::TestCase
def test_conversion_to_string
Loan.instance_eval { @time_class = FakeTime }
loan = Loan.new('War and Peace')
assert_equal 'WAR AND PEACE loaned on Mon Apr 06 12:15:50', loan.to_s
end
end
Bill is quite proud of his own coding prowess. He says, “I think we deserve a break—after I give you a quiz.”
Download
Copyright Disclaimer:
This site does not store any files on its server. We only index and link
to content provided by other sites. Please contact the content providers
to delete copyright contents if any and email us, we'll remove relevant
links or contents immediately.